@extends('home.base.main')
@section('content')
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 ,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

<title>结算页面</title>

<link href="{{ asset('AmazeUI-2.4.2/assets/css/amazeui.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('basic/css/demo.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/cartstyle.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/jsstyle.css') }}" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{{ asset('js/address.js') }}"></script>

<div class="concent">
	<!--地址-->
	<div class="paycont">
		<div class="address">
			<h3>确认收货地址 </h3>
			<div class="control">
				<a href="{{ url('home/address') }}">
					<div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>
				</a>
			</div>
			<div class="clear"></div>
			<form  method='post' name='myform'>
				{{ csrf_field() }}
				{{ method_field('DELETE') }}
			</form>
			<ul>
				<div class="per-border"></div>
				@foreach($ob as $a)
				<li class="user-addresslist defaultAddr">
					<div class="address-left">
						<div class="user DefaultAddr">
							<span class="buy-address-detail">   
	       						<span class="buy-user">{{ $a->consignee }} </span>
								<span class="buy-phone">{{ $a->telephone }}</span>
							</span>
						</div>
						<div class="default-address DefaultAddr">
							<span class="buy-line-title buy-line-title-type">收货地址：</span>
							<span class="buy--address-detail">
						   		{{ $a->address }}
							</span>
							</span>
						</div>
					</div>
					<div class="address-right">
						<a href="../person/address.html">
							<span class="am-icon-angle-right am-icon-lg"></span>
						</a>
					</div>
					<div class="clear"></div>
					<div class="new-addr-btn">
						<a href="#" class="hidden">设为默认</a>
						<span class="new-addr-bar hidden">|</span>
						<a href="{{ url('home/address').'/'.$a->id.'/edit' }}">编辑</a>
						<span class="new-addr-bar">|</span>
						<a href="javascript:doDel({{ $a->id }})" onclick="delClick(this);">删除</a>
					</div>
				</li>
				@endforeach
				<li class="user-addresslist">
					<div class="address-left">
						<div class="user DefaultAddr">
							<span class="buy-address-detail">   
  							 <span class="buy-user">艾迪 </span>
							<span class="buy-phone">15877777777</span>
							</span>
						</div>
						<div class="default-address DefaultAddr">
							<span class="buy-line-title buy-line-title-type">收货地址：</span>
							<span class="buy--address-detail">
					   <span class="province">湖北</span>省
							<span class="city">武汉</span>市
							<span class="dist">武昌</span>区
							<span class="street">东湖路75号众环大厦9栋9层999</span>
							</span>
							</span>
						</div>
						<ins class="deftip hidden">默认地址</ins>
					</div>
					<div class="address-right">
						<span class="am-icon-angle-right am-icon-lg"></span>
					</div>
					<div class="clear"></div>
					<div class="new-addr-btn">
						<a href="#">设为默认</a>
						<span class="new-addr-bar">|</span>
						<a href="#">编辑</a>
						<span class="new-addr-bar">|</span>
						<a href="javascript:void(0);"  onclick="delClick(this);">删除</a>
					</div>
				</li>
				<div class="per-border"></div>				
			</ul>
			<script>
				function doDel(id){
					if(confirm('确定删除吗？')){
						var form = document.myform;
						form.action = '/home/address/'+id;
						form.submit();
					}
				}
			</script>
			<div class="clear"></div>
		</div>
		<!--物流-->
		<div class="logistics">
			<h3>选择物流方式</h3>
			<ul class="op_express_delivery_hot">
				<li data-value="yuantong" class="OP_LOG_BTN  "><i class="c-gap-right" style="background-position:0px -468px"></i>圆通<span></span></li>
				<li data-value="shentong" class="OP_LOG_BTN  "><i class="c-gap-right" style="background-position:0px -1008px"></i>申通<span></span></li>
				<li data-value="yunda" class="OP_LOG_BTN  "><i class="c-gap-right" style="background-position:0px -576px"></i>韵达<span></span></li>
				<li data-value="zhongtong" class="OP_LOG_BTN op_express_delivery_hot_last "><i class="c-gap-right" style="background-position:0px -324px"></i>中通<span></span></li>
				<li data-value="shunfeng" class="OP_LOG_BTN  op_express_delivery_hot_bottom"><i class="c-gap-right" style="background-position:0px -180px"></i>顺丰<span></span></li>
			</ul>
		</div>
		<div class="clear"></div>
		<!--支付方式-->
		<div class="logistics">
			<h3>选择支付方式</h3>
			<ul class="pay-list">
				<li class="pay card"><img src="{{ asset('images/wangyin.jpg') }}" />银联<span></span></li>
				<li class="pay qq"><img src="{{ asset('images/weizhifu.jpg') }}" />微信<span></span></li>
				<li class="pay taobao"><img src="{{ asset('images/zhifubao.jpg') }}" />支付宝<span></span></li>
			</ul>
		</div>
		<div class="clear"></div>
		<!--订单-->
		<div class="concent">
			<div id="payTable">
				<h3>确认订单信息</h3>
				<div class="cart-table-th">
					<div class="wp">
						<div class="th th-item">
							<div class="td-inner">商品信息</div>
						</div>
						<div class="th th-price">
							<div class="td-inner">单价</div>
						</div>
						<div class="th th-amount">
							<div class="td-inner">数量</div>
						</div>
						<div class="th th-sum">
							<div class="td-inner">金额</div>
						</div>
						<div class="th th-oplist">
							<div class="td-inner">配送方式</div>
						</div>
					</div>
				</div>
				<div class="clear"></div>				
				</div>
				<tr id="J_BundleList_s_1911116345_1" class="item-list">
					<div id="J_Bundle_s_1911116345_1_0" class="bundle  bundle-last">
						<div class="bundle-main">
							<ul class="item-content clearfix">
								<div class="pay-phone">
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" class="J_MakePoint">
												<img src="{{ asset('admin/upload').'/'.$detail->pic }}" class="itempic J_ItemImg" width="80" height="80"></a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色" class="item-title J_MakePoint" data-point="tbcart.8.11">{{ $detail->title }}</a>
											</div>
										</div>
									</li>
									<li class="td td-info">
										<div class="item-props">
											<span class="sku-line">颜色：10#蜜橘色+17#樱花粉</span>
											<span class="sku-line">包装：两支手袋装（送彩带）</span>
										</div>
									</li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<em class="J_Price price-now">{{ $detail->price }}</em>
											</div>
										</div>
									</li>
								</div>
								<li class="td td-amount">
									<div class="amount-wrapper ">
										<div class="item-amount ">
											<span class="phone-title">购买数量</span>
											<div class="sl">
												<input id="domin" class="am-btn" name="" type="button" value="-" />

												<input id="text_box" class="text_box" name="" type="text" value="{{ $amount }}" style="width:30px;" />

												<input id="doadd" class="am-btn" name="" type="button" value="+" />
											</div>
										</div>
									</div>
								</li>
								<li class="td td-sum">
									<div class="td-inner">
										<em tabindex="0" id="sum" class="J_ItemSum number">{{ $sum }}</em>
									</div>
								</li>
								<li class="td td-oplist">
									<div class="td-inner">
										<span class="phone-title">配送方式</span>
										<div class="pay-logis">
											包邮
										</div>
									</div>
								</li>
							</ul>
							<script type="text/javascript">								
								document.getElementById("domin").onclick = function domin(){
									if(document.getElementById('text_box').value > 1){
										var domin = document.getElementById('text_box').value;
										domin = eval(parseInt(document.getElementById('text_box').value) - 1);
										document.getElementById('text_box').value = domin;
										document.getElementById('sum').innerHTML = domin * {{ $detail->price }};
										document.getElementById('sumb').innerHTML = document.getElementById('sum').innerHTML;
										document.getElementById('sumc').innerHTML = document.getElementById('sum').innerHTML;
									}
								}								
								document.getElementById("doadd").onclick = function doadd(){
									var doadd = document.getElementById('text_box').value;
									doadd = eval(parseInt(document.getElementById('text_box').value) + 1);
									document.getElementById('text_box').value = doadd;
									document.getElementById('sum').innerHTML = doadd * {{ $detail->price }};
									document.getElementById('sumb').innerHTML = document.getElementById('sum').innerHTML;
									document.getElementById('sumc').innerHTML = document.getElementById('sum').innerHTML;
								}							
							</script>
							<div class="clear"></div>
						</div>
				</tr>
				</div>
				<div class="clear"></div>
				<div class="pay-total">
				<!--留言-->
				<div class="order-extra">
					<div class="order-user-info">
						<div id="holyshit257" class="memo">
							<label>买家留言：</label>
							<input type="text" title="选填,对本次交易的说明（建议填写已经和卖家达成一致的说明）" placeholder="选填,建议填写和卖家达成一致的说明" class="memo-input J_MakePoint c2c-text-default memo-close">
							<div class="msg hidden J-msg">
								<p class="error">最多输入500个字符</p>
							</div>
						</div>
					</div>
				</div>
				<!--优惠券-->
				<div class="buy-agio">
					<li class="td td-coupon">
						<span class="coupon-title">优惠券</span>
						<select data-am-selected>
							<option value="a">
								<div class="c-price">
									<strong>￥8</strong>
								</div>
								<div class="c-limit">
									【消费满95元可用】
								</div>
							</option>
							<option value="b" selected>
								<div class="c-price">
									<strong>￥3</strong>
								</div>
								<div class="c-limit">
									【无使用门槛】
								</div>
							</option>
						</select>
					</li>
					<li class="td td-bonus">
						<span class="bonus-title">红包</span>
						<select data-am-selected>
							<option value="a">
								<div class="item-info">
									¥50.00<span>元</span>
								</div>
								<div class="item-remainderprice">
									<span>还剩</span>10.40<span>元</span>
								</div>
							</option>
							<option value="b" selected>
								<div class="item-info">
									¥50.00<span>元</span>
								</div>
								<div class="item-remainderprice">
									<span>还剩</span>50.00<span>元</span>
								</div>
							</option>
						</select>
					</li>
				</div>
				<div class="clear"></div>
				</div>
				<!--含运费小计-->
				<div class="buy-point-discharge ">
					<p class="price g_price ">
						合计（含运费） <span>¥</span><em id="sumb" class="pay-sum">{{ $sum }}</em>
					</p>
				</div>
				<!--信息-->
				<div class="order-go clearfix">
					<div class="pay-confirm clearfix">
						<div class="box">
							<div tabindex="0" id="holyshit267" class="realPay">
								<em class="t">实付款：</em>
								<span class="price g_price ">
	                       			<span>¥</span>
	                       			<em class="style-large-bold-red " id="sumc">{{ $sum }}</em>
								</span>
							</div>
							<div id="holyshit268" class="pay-address">
								<p class="buy-footer-address">
									<span class="buy-line-title buy-line-title-type">寄送至：</span>
									<span class="buy--address-detail">
						   				<span class="province">湖北</span>省
										<span class="city">武汉</span>市
										<span class="dist">洪山</span>区
										<span class="street">雄楚大道666号(中南财经政法大学)</span>
									</span>
									<!-- </span> -->
								</p>
								<p class="buy-footer-address">
									<span class="buy-line-title">收货人：</span>
									<span class="buy-address-detail">   
	                             		<span class="buy-user">{{ session('uname') }}</span>
										<span class="buy-phone">15871145629</span>
									</span>
								</p>
							</div>
						</div>
						<div id="holyshit269" class="submitOrder">
							<div class="go-btn-wrap">
								<!-- <a id="J_Go" href="{{ url('home/doPay'.'/'.$detail->id) }}" class="btn-go" tabindex="0" title="点击此按钮，提交订单">提交订单</a> -->
								<form id="pid">
									{{ csrf_field() }}
									{{ method_field('PUT') }}
									<a id="J_Go" href="javascript:onclick(doPay())" class="btn-go" tabindex="0" title="点击此按钮，提交订单">提交订单</a>									
									<!-- 将商品id和购买数量，通过隐藏域进行传值 -->
									<input type="hidden" name="pid" value="{{ $detail->id }}">
									<input type="hidden" name="amount" value="" id="hamount">
									<input type="hidden" name="money" value="" id="money">
								</form>
							</div>
							<script type="text/javascript">
								function doPay(){
									myform = document.getElementById('pid');
									// 获取用户选择的商品数量
									amount = document.getElementById('text_box').value;
									// money = document.getElementById('money').value;
									// 将用户选择的商品数量赋值给隐藏域传给后台
									document.getElementById('hamount').value = amount;
									document.getElementById('money').value = document.getElementById('sumc').innerHTML;
									myform.action = "{{ url('home/doPay'.'/'.$detail->id) }}";
									myform.method = 'post';
									myform.submit();
								}
							</script>							
						</div>
						<div class="clear"></div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
@endsection